//
//  CreateCartoonViewController.m
//  drawacartoon
//
//  Created by Ji Hu on 12-7-18.
//  Copyright (c) 2012年 爱辅导. All rights reserved.
//

#import "CreateCartoonViewController.h"
#import "File.h"

@interface CreateCartoonViewController ()

@end

@implementation CreateCartoonViewController

@synthesize titleField=_titleField;
@synthesize delegate=_delegate;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
	return YES;
}

-(void)okClick:(id)sender{
    
    NSString *dpath =[NSString stringWithFormat:@"%@/%@",[File cartoonDirectoryPath],_titleField.text];
    
    NSFileManager *fm = [NSFileManager defaultManager];
    if ([fm fileExistsAtPath:dpath]==NO) {
        [fm createDirectoryAtPath:dpath withIntermediateDirectories:NO attributes:nil error:nil];
    }
    
    [self.delegate operate:Operate_OK withObject:self.titleField.text];
}

-(void)cancelClick:(id)sender{
    [self.delegate operate:Operate_Cancel withObject:nil];
}

@end
